@echo off
echo building...
set needsvn=false
if not exist v8 set needsvn=true
if not exist v8\SConstruct set needsvn=true
if %needsvn%==true (
  rmdir /s /q v8container 2>NUL
  :: need this container for TortoiseSVN/svn command-line conflicts :)
  mkdir v8container
  cd v8container
  call svn co -q http://v8.googlecode.com/svn/branches/bleeding_edge/ v8
  if %ERRORLEVEL% NEQ 0 exit /B %ERRORLEVEL%
  cd ..
  move v8container\v8 .
  rmdir /s /q v8container
)
:: call perl -i".bak" -ple "s/'\/O2', '\/GL'/'\/O2'/g" v8\SConstruct >NUL
:: call perl -i".bak" -ple "s/'\/OPT:REF', '\/OPT:ICF', '\/LTCG'/'\/OPT:REF', '\/OPT:ICF'/g" v8\SConstruct >NUL
:: del /Q v8\SConstruct.bak >NUL
cd v8
call svn update -q
:: call scons msvcltcg=off %sconspaths% sample="shell" >NUL
call scons %sconspaths% d8
if %ERRORLEVEL% NEQ 0 goto failure
cd ..
:: del /Q ..\bin\v8.exe >NUL 2>NUL
:: move v8\shell.exe ..\bin\ >NUL
:: ren ..\bin\shell.exe v8.exe >NUL
echo finished.
goto finished

:failure
echo Build error.
cd ..

:finished
:: set OLDDIR=
:: set PATH=%OLDPATH%
:: set sconspaths=

:reallydone
